<?php

/**
 * @Author: zhibinm (113664000@qq.com)
 * @Date:   2018-04-20 08:50:50 
 * @Copyright:   xuebingsi
 * @Last Modified by:   Zhibinm
 * @Last Modified time: 2018-04-20 09:23:32
 */

$username = $_POST['username'];

$code = $_POST['code'];

include './common.php';

$oldUser = getData('./db/user.txt');

foreach ($oldUser as  $user) {
	if($username==$user['username']){

		echo json_encode(['error'=>1,'info'=>'用户名已存在']);
		exit();
		// var_dump('用户名已存在');exit;
	}
}

if(strtolower($_SESSION['code'])<>strtolower($code)){
	echo json_encode(['error'=>2,'info'=>'验证码不正确']);
		exit();
}


echo json_encode(['error'=>0,'info'=>'数据正常']);
		exit();


// echo json_encode(['error'=>0,'info'=>'用户名可以用']);
// exit();

// var_dump('用户名可以用');

// echo json_encode(['zxhin'=>90]);